/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package dao.proposition;

import entities.Proposition;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

/**
 *
 * @author aurelien.emery
 */
@ManagedBean
@RequestScoped
public class TestProposition {


    @EJB
    private DaoPropositionLocal daoProposition;

    /** Creates a new instance of TestProposition */
    public TestProposition() {
    }

    public void tester() {
        testProposition();
        System.out.println("-------------------------------------------------------------------");
}

    private void testProposition() {
        System.out.println("test daoProposition");
        try {
            int nb = daoProposition.count();
            if (nb <= 0) {
                System.err.println("echec de count : aucun enregistrement");
            } else {
                System.out.println("nb enregistrement : " + nb);
            }
            List<Proposition> qc = daoProposition.findAll();
            if (qc.isEmpty()) {
                System.err.println("echec de findAll : liste vide");
            } else {
                for (Proposition prop : qc) {
                    System.out.println(prop.getTexte()+" : "+prop.getValeur());
                }
            }
        } catch (Exception ex) {
            System.err.println("echec count daoProposition : " + ex.getClass().toString());
        }

    }

}
